import * as PIXI from 'pixi.js'

export default (textureSource: PIXI.TextureSource) => {
  const typeArr = [
    {
      name: 'lives',
      text: '生灵',
    },
    {
      name: 'magic',
      text: '法术',
    },
    {
      name: 'equip',
      text: '装备',
    },
  ]
  const container = new PIXI.Container()
  const texture = new PIXI.Texture({
    source: textureSource,
    frame: new PIXI.Rectangle(1530, 773, 124, 50),
  })
  const selectedTexture = new PIXI.Texture({
    source: textureSource,
    frame: new PIXI.Rectangle(1440, 1259, 124, 50),
  })
  typeArr.forEach((type, index, arr) => {
    const typeContainer = new PIXI.Container()
    const sprite = new PIXI.Sprite(texture)
    typeContainer.addChild(sprite)
    const selectedSprite = new PIXI.Sprite(selectedTexture)
    typeContainer.addChild(selectedSprite)
    selectedSprite.alpha = 0
    const typeText = new PIXI.Text({
      text: type.text,
      style: {
        fontFamily: 'XQFont',
        fontSize: 38,
        fill: 'rgb(88, 75, 49)',
        align: 'center',
      },
    })
    typeText.anchor.set(0.5)
    typeText.position.set(135 / 2 + 12, 24)
    typeContainer.addChild(typeText)
    typeContainer.position.set(1919 - 453 - 61 - (135 + 12) * (arr.length - index), 96 / 2)
    container.addChild(typeContainer)
  })
  return container
}
